//////////////////////////////////////////////////////////////////////////
//
// This file is a part of APNS provider project.
// Copyright (c) Vladimir Gumenuk, 2013-2014.
//
// PROJECT:         APNS provider
// FILE:            apns.h - main apns header
// AUTHOR:          Vladimir Gumenuk
// DATE:            22-Dec-2013
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////

#ifndef __apns_h__
#define __apns_h__

#define MAX_NTFS_LEN     256
#define DEVICE_TOKEN_LEN 32

typedef struct tagDeviceToken
{
    BYTE tok[DEVICE_TOKEN_LEN];
} DeviceToken;

typedef struct tagDeviceInfo
{
    char        szUserName[64];
    char        szBundleId[64];
    DeviceToken token; 
} DeviceInfo;

//////////////////////////////////////////////////////////////////////////
//
interface IPushNotification : public IUnknown
{
    STDMETHOD (Init)( DWORD dwExpiration, BYTE bPriority, const DeviceToken& deviceToken, LPCSTR lpszPayload ) PURE;
    STDMETHOD (SetPayload)( LPCSTR lpszPayload ) PURE;
    STDMETHOD (Makeup)( DWORD dwType, IGMSBuffer **ppOut ) PURE;
    STDMETHOD_(DWORD,GetID)() PURE;
};

HRESULT __stdcall CreatePushNotification( IPushNotification **ppOut );

//////////////////////////////////////////////////////////////////////////
//
interface IAPNSClient : public IUnknown
{
    STDMETHOD(Connect)( IGMSNetwork *pNet, LPCTSTR lpszCertSubject, LPCTSTR lpszServerName, DWORD dwPortNumber ) PURE;
    STDMETHOD(Disconnect)() PURE;
    STDMETHOD(SendNotification)( IPushNotification *pNtfs ) PURE;
};

HRESULT __stdcall CreateAPNSClient( IAPNSClient **ppOut );

extern "C" const IID IID_IPushNotification;
extern "C" const IID IID_IAPNSClient;

// {59a6ad79-7caf-49e0-b028-fb95d8c6dd89}
DEFINE_GUID(IID_IPushNotification, 
    0x59a6ad79, 0x7caf, 0x49e0, 0xb0, 0x28, 0xfb, 0x95, 0xd8, 0xc6, 0xdd, 0x89);

// {8ddddd6f-c925-4942-9e11-468656d1d821}
DEFINE_GUID(IID_IAPNSClient,
    0x8ddddd6f, 0xc925, 0x4942, 0x9e, 0x11, 0x46, 0x86, 0x56, 0xd1, 0xd8, 0x21);

#endif // __apns_h__